package cc.geguol;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 作者  Administrator
 * 时间  2017/3/30 14:49
 * 文件  JDBCDemo
 * 描述
 */
public class JdbcUtil {
	private static String url = "jdbc:mysql://localhost:3306/proccess";
	private static String user = "root";
	private static String password = "root";

	public static Connection getconn() throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");
		return  DriverManager.getConnection(url,user,password);
	}

	public void closeAll(Connection conn, PreparedStatement statement, ResultSet resultSet){
		if (resultSet != null) {
			try {
				resultSet.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

		if (conn != null) {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}
